<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../vue 2.6.10.js"></script>
</head>

<body>
    <div id="app">
        <App></App>
        <br><br>
        <Count></Count>
    </div>
    <script>
        Vue.config.productionTip = false;

        const App = Vue.extend({
            template: `
            <div>
                <div>App组件</div>
                <button @click="show">点击</button>
            </div>
            `,
            // data(){
            //     return {
            //         count:0
            //     }
            // },
            methods: {
                show() {
                    console.log(this);
                    console.log(this.$and);
                    console.log(this.__proto__) //VueComponent.proptype
                    console.log(this.__proto__.__proto__) // Vue.prototype
                    console.log(this.__proto__.__proto__.__proto__) // Object.prototype
                    console.log(this.__proto__.__proto__.__proto__.__proto__) // null
                }
            },
        })


        const Count = Vue.extend({
            template: `
            <div>
                <div>Count组件</div>
                <button @click="show">点击</button>
            </div>
            `,
            // Vue的构造函数的原型对象上扩展一个属性或者方法,则所有的组件实例都可以访问
            methods: {
                show() {
                    console.log(this); // 组件实例化对象 VueComponent
                    console.log(this.$and); // 1 
                    console.log(this.__proto__) //VueComponent.proptype
                    console.log(this.__proto__.__proto__) // Vue.prototype
                    console.log(this.__proto__.__proto__.__proto__) // Object.prototype
                    console.log(this.__proto__.__proto__.__proto__.__proto__) // null
                }
            },
        })

        
        Vue.prototype.$and = "1";

        const vm = new Vue({
            el: "#app",
            data() {
                return {}
            },
            components: {
                App,
                Count
            }
        })

    </script>
</body>

</html>